#include<iostream>
#include<unistd.h>
#include"thread.hpp"

void hello1()
{
    char buffer[64];
    pthread_getname_np(pthread_self(),buffer,sizeof(buffer)-1);
    while(true)
    {
        std::cout<<"hello world," <<buffer<<std::endl;
        sleep(1);
    }
}

void hello2()
{
      char buffer[64];
    pthread_getname_np(pthread_self(),buffer,sizeof(buffer)-1);
    while(true)
    {
        std::cout<<"hello world," <<buffer<<std::endl;
        sleep(1);
    }
}



int  main()
{
    pthread_setname_np(pthread_self(),"main");
    ThreadModule::Thread t1(hello1);
    t1.start();

    ThreadModule::Thread t2(std::bind(&hello2));//bind用于​​绑定函数参数​​，生成一个新的可调用对象
    t2.start();

    t1.join();
    t2.join();

    return 0;


}
